const ADD_COUNT = 'ADD_COUNT'

const initState = {
  count: 1,
};

interface AddCountState {
	type: typeof ADD_COUNT
	payload: number
}

export function addCountActionCreator(payload: number = 1): AddCountState {
	return { type: ADD_COUNT, payload }
}

type TestAction = AddCountState

const reducerTest = (state = initState, action: TestAction) => {
  switch (action.type) {
    case ADD_COUNT:
      return {
        ...state,
        count: state.count + action.payload,
      };
    default:
      return state;
  }
};

export default reducerTest